﻿<%@ Page Title="" Language="C#" MasterPageFile="~/PortalParts/PageMore.Master" AutoEventWireup="true" CodeBehind="Suggestion.aspx.cs" Inherits="ZHDJ.Web.Portal.CadreWork.Suggestion" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script src="../../Resource/js/default/jquery.tmpl.min.js"></script>
    <script src="../../Resource/js/knockout/knockout-3.4.0.js"></script>
    <script src="../../Resource/js/jquery/jquery.pagination.js"></script>

    <script type="text/javascript">
        var pageSize = 5, isBind = false;
        var paginationPara = {
            num_edge_entries: 1, //边缘页数
            num_display_entries: 4, //主体页数
            callback: pageselectCallback,
            items_per_page: pageSize, //每页显示1项
            prev_text: "上一页",
            next_text: "下一页",
            link_to: "javascript:void(0);"
        }
        var ViewModel = {
            qdate: ko.observableArray(),
            loadContacts: function (pageIndex) {
                $.get("Suggestion.aspx", {
                    PageIndex: pageIndex,
                    PageSize: pageSize,
                    Search: $("#txtSearch").val(),
                    Status: $("#selectStatus").val(),
                    r: (new Date()).getTime()
                },
                function (data) {
                    ViewModel.qdate(eval("(" + data + ")"));
                });
            }
        }

        function initPage() {
            $.get("Suggestion.aspx", { DataCount: 1, PageSize: pageSize, Search: $("#txtSearch").val(), Status: $("#selectStatus").val(), r: (new Date()).getTime() },
                function (data) {
                    var totalCount = parseInt(data);
                    $("#pagination").pagination(totalCount, paginationPara);
                });
        }
        function pageselectCallback(pageIndex, jq) {
            ViewModel.loadContacts(pageIndex);
            if (!isBind) {
                ko.applyBindings(ViewModel);
                isBind = true;
            }
        }

        function isNumber(KeyCode) {
            //如果输入的字符是在0-9之间
            if (((KeyCode > 47) && (KeyCode < 58))) {
                return true;
            }
            else {
                return false;
            }
        }

        var result = false;
        function IsContainSensitiveWords(value) {
            $.ajax({
                url: "Suggestion.aspx/IsContainSensitiveWords",
                async: false,
                type: "post",
                dataType: "json",
                contentType: "application/json",
                data: "{content:\"" + value + "\"}",
                success: function (data) {
                    result = data.d == "success";
                },
                error: function (XMLHttpRequest) {

                }
            })
        }

        String.isNullOrEmpty = function (value) {
            if (value == null || value == "")
                return true;
            else
                return false;
        }

        $(function () {
            initPage();
            $("#btnQuery").click(function () {
                initPage();
            });

            $("#ctl00_ContentPlaceHolder1_Form1_sdfsdf_btnSave").click(function () {
                var userName = $("#ctl00_ContentPlaceHolder1_Form1_sdfsdf_txtUserName-inputEl").val();
                var mobileNo = $("#ctl00_ContentPlaceHolder1_Form1_sdfsdf_txtMobileNo-inputEl").val();
                var title = $("#ctl00_ContentPlaceHolder1_Form1_sdfsdf_txtTitle-inputEl").val();
                var content = $("#ctl00_ContentPlaceHolder1_Form1_sdfsdf_txtContent-inputEl").val();

                if (String.isNullOrEmpty(userName)) {
                    alert("请输入姓名！");
                    return false;
                }
                else {
                    IsContainSensitiveWords(userName);
                    if (!result) {
                        alert("您输入的姓名存在敏感词，请确认后重试！");
                        return false;
                    }
                }

                if (String.isNullOrEmpty(mobileNo)) {
                    alert("请输入联系方式！");
                    return false;
                }

                if (String.isNullOrEmpty(title)) {
                    alert("请输入主题！");
                    return false;
                }
                else {
                    IsContainSensitiveWords(title);
                    if (!result) {
                        alert("您输入的主题存在敏感词，请确认后重试！");
                        return false;
                    }
                }

                if (String.isNullOrEmpty(content)) {
                    alert("请输入内容！");
                    return false;
                }
                else {
                    IsContainSensitiveWords(content);
                    if (!result) {
                        alert("您输入的内容存在敏感词，请确认后重试！");
                        return false;
                    }
                }

                return true;
            });

            $("#ctl00_ContentPlaceHolder1_Form1_sdfsdf_btnReset").click(function () {
                $("#ctl00_ContentPlaceHolder1_Form1_sdfsdf_txtUserName-inputEl").val("");
                $("#ctl00_ContentPlaceHolder1_Form1_sdfsdf_txtMobileNo-inputEl").val("");
                $("#ctl00_ContentPlaceHolder1_Form1_sdfsdf_txtTitle-inputEl").val("");
                $("#ctl00_ContentPlaceHolder1_Form1_sdfsdf_txtContent-inputEl").val("");

                return false;
            });

            $("#ctl00_ContentPlaceHolder1_Form1_sdfsdf_txtMobileNo_wrapper").keydown(function (e) {
                var mobile = $("#ctl00_ContentPlaceHolder1_Form1_sdfsdf_txtMobileNo-inputEl").val();
                if (e.keyCode != 8 && (!isNumber(e.keyCode) || mobile.length >= 11)) {
                    e.stopPropagation();
                    return false;
                }
            });
        });

    </script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <f:PageManager ID="PageManager1" runat="server" />
    <div class="morequerybar">
        <table>
            <tr>
                <td>
                    <span style="color: #060001;font-size: 14px;">主题：</span>
                </td>
                <td>
                    <input id="txtSearch" type="text" class="text1" style="width: 200px" />
                </td>
                <td style="width: 70px; text-align: right;"><span style="color: #060001;font-size: 14px;">类别：</span></td>
                <td style="width: 150px;">
                    <select id="selectStatus" class="text1">
                        <option value="">请选择</option>
                        <option value="0">待回复</option>
                        <option value="1">已回复</option>
                    </select>
                </td>
                <td>
                    <button type="button" class="mybtn" id="btnQuery" style="height:38px;line-height: 38px;">查询</button>
                </td>
            </tr>
        </table>
    </div>
    <div class="cztable" style="margin-top: 20px;">
        <table class="table_b" border="0" cellspacing="0" cellpadding="0">
<%--            <tr>
                <td colspan="4" class="red" style="height: 30px; line-height: 30px; padding-left: 10px; color: #fff; font-size: 14px; font-weight: 700;">主题</td>
            </tr>--%>
            <tr>
                <td>主题</td>
                <td>状态</td>
                <td>留言时间</td>
                <td>回复时间</td>
            </tr>
            <!-- ko foreach: qdate -->
            <tr>
                <td class="td1" data-bind="text: Title"></td>
                <td class="td2" data-bind="text: StatusName"></td>
                <td class="td2" data-bind="text: CreateTime.replace('T', ' ')"></td>
                <td class="td2" data-bind="text: ModifyTime.replace('T', ' ')"></td>
            </tr>
            <!-- /ko -->
        </table>
    </div>
    <div class="pagination" style="margin-top: 20px;">
        <div id="pagination">
        </div>
    </div>
    <f:Form runat="server" ShowBorder="false" ShowHeader="false" ID="Form1">
        <Items>
            <f:ContentPanel runat="server" ID="sdfsdf" ShowBorder="false">


                <div class="cztable mycustomtable" style="margin-top: 20px;">
                    <div style="width:100%;background:#f2f2f2;margin-bottom: 20px;">
                        <span style="display: inline-block;font-size:16px;font-weight:bold;background:#fff;height: 50px;line-height: 50px;color: #171717;padding:0 20px;border-top: solid 2px #ea0900;">历史留言</span>
                    </div>
                    <table class="table_b" border="0" cellspacing="0" cellpadding="0" style="background: #f7f7f7;">
                        <tr class="tr_b">
                            <th class="th_b">姓名</th>
                            <td class="td_b">
                                <f:TextBox ID="txtUserName" Width="557px" runat="server" Required="true" ShowRedStar="true" MaxLength="10">
                                </f:TextBox>
                            </td>
                        </tr>
                        <tr class="tr_b">
                            <th class="th_b">联系方式</th>
                            <td class="td_b">
                                <f:TextBox ID="txtMobileNo" Width="557px" runat="server" Required="true" RequiredMessage="请输入联系方式" ShowRedStar="true" MaxLength="20">
                                </f:TextBox>
                            </td>
                        </tr>
                        <tr class="tr_b">
                            <th class="th_b">主题</th>
                            <td colspan="3" class="td_b">
                                <f:TextBox ID="txtTitle" runat="server" Width="557px" Required="true" ShowRedStar="true" MaxLength="200"></f:TextBox>
                            </td>
                        </tr>
                        <tr class="tr_b">
                            <th class="th_b">内容</th>
                            <td colspan="3" class="td_b">
                                <f:TextArea runat="server" ID="txtContent" Height="100px" Width="557px"></f:TextArea>
                            </td>
                        </tr>
                    </table>
					<table class="table_b" border="0" cellspacing="0" cellpadding="0" style="border: none;margin-top: 20px;">
						<tr class="tr_b">
                            <td class="td_b" style="text-align: center">
                                <asp:Button ID="btnSave" runat="server" Text="提交" CssClass="mybtn mybtn2" OnClick="btnSave_Click" />
                                <asp:Button ID="btnReset" runat="server" CssClass="mybtn mybtn2" Text="重置" />
                            </td>
                        </tr>
					</table>
                </div>
            </f:ContentPanel>
        </Items>
    </f:Form>
</asp:Content>
